<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/style.css"/>
    <script type="text/javascript" src="__PUBLIC__/Js/jquery.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Js/bootstrap.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Js/ckform.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Js/common.js"></script>
    <link href="http://g.alicdn.com/bui/bui/1.1.16/css/bs3/dpl.css" rel="stylesheet">
    <link href="http://g.alicdn.com/bui/bui/1.1.16/css/bs3/bui.css" rel="stylesheet">
    <script src="http://g.alicdn.com/bui/seajs/2.3.0/sea.js"></script>
    <script src="http://g.alicdn.com/bui/bui/1.1.16/config.js"></script>


    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<form class="form-inline definewidth m20" action="<?php echo U('index');?>?id=<?php echo ($id); ?>&data=<?php echo ($data); ?>" method="post">
    时间列名：
    <input type="text" name="datename" id="datename" class="abc input-default" placeholder=""
           value="<?php echo I('datename'); ?>">&nbsp;&nbsp;
    <label>开始时间：</label><input name="datestart" id="datestart" type="text" value="<?php echo I('datestart'); ?>"
                               class="calendar calendar-time"/>
    <label>结束时间：</label><input name="dateend" id="dateend" type="text" value="<?php echo I('dateend'); ?>"
                               class="calendar calendar-time"/>
    查询列名1：
    <input type="text" name="leykey1" id="leykey1" class="abc input-default" placeholder=""
           value="<?php echo I('leykey1'); ?>">&nbsp;&nbsp;
    <label class="control-label">选择框：</label><select name="xuanze1" id="xuanze1">
    <option
    <?php if(I('xuanze1') == '请选择'){ echo 'selected'; } ?> >请选择</option>
    <option
    <?php if(I('xuanze1') == '大于'){ echo 'selected'; } ?> >大于</option>
    <option
    <?php if(I('xuanze1') == '等于'){ echo 'selected'; } ?> >等于</option>
    <option
    <?php if(I('xuanze1') == '小于'){ echo 'selected'; } ?> >小于</option>
    <option
    <?php if(I('xuanze1') == '包含'){ echo 'selected'; } ?> >包含</option>
</select>
    查询值1：
    <input type="text" name="leyval1" id="leyval1" class="abc input-default" placeholder=""
           value="<?php echo I('leyval1'); ?>">&nbsp;&nbsp;
    <p></p>
    查询列名2：
    <input type="text" name="leykey2" id="leykey2" class="abc input-default" placeholder=""
           value="<?php echo I('leykey2'); ?>">&nbsp;&nbsp;

    <label class="control-label">选择框：</label><select name="xuanze2" id="xuanze2">
    <option
    <?php if(I('xuanze2') == '请选择'){ echo 'selected'; } ?> >请选择</option>
    <option
    <?php if(I('xuanze2') == '大于'){ echo 'selected'; } ?> >大于</option>
    <option
    <?php if(I('xuanze2') == '等于'){ echo 'selected'; } ?> >等于</option>
    <option
    <?php if(I('xuanze2') == '小于'){ echo 'selected'; } ?> >小于</option>
    <option
    <?php if(I('xuanze2') == '包含'){ echo 'selected'; } ?> >包含</option>
</select>
    查询值2：
    <input type="text" name="leyval2" id="leyval2" class="abc input-default" placeholder=""
           value="<?php echo I('leyval2'); ?>">&nbsp;&nbsp;&nbsp;&nbsp;
    查询列名3：
    <input type="text" name="leykey3" id="leykey3" class="abc input-default" placeholder=""
           value="<?php echo I('leykey3'); ?>">&nbsp;&nbsp;
    <label class="control-label">选择框：</label><select name="xuanze3" id="xuanze3">
    <option
    <?php if(I('xuanze3') == '请选择'){ echo 'selected'; } ?> >请选择</option>
    <option
    <?php if(I('xuanze3') == '大于'){ echo 'selected'; } ?> >大于</option>
    <option
    <?php if(I('xuanze3') == '等于'){ echo 'selected'; } ?> >等于</option>
    <option
    <?php if(I('xuanze3') == '小于'){ echo 'selected'; } ?> >小于</option>
    <option
    <?php if(I('xuanze3') == '包含'){ echo 'selected'; } ?> >包含</option>
</select>
    查询值3：
    <input type="text" name="leyval3" id="leyval" class="abc input-default" placeholder=""
           value="<?php echo I('leyval3'); ?>">&nbsp;&nbsp;
    </p>
    <p></p>

    <p>
        <button type="submit" class="btn btn-primary">查询</button>
        &nbsp;&nbsp;
        <button type="button" class="btn btn-success" onClick="caochu();" >导出</button>
        <?php if($data == 'shoplist' ){ ?>
        <button type="button" class="btn btn-success" onClick="add();" id="add">新增</button>
         <?php } ?>
    </p>
</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <?php foreach($datas[0] as $k => $v){ ?>
        <th><?php echo $k; ?></th>
        <?php } ?>
        <?php if($data == 'shoplist'){ ?>
        <th>操作</th>
        <?php } ?>
    </tr>
    </thead>
    <?php  foreach($datas as $k => $v){ ?>
    <tr>
        <?php foreach($v as $keys => $values){ ?>
        <td> <?php echo $values; ?> </td>
        <?php } ?>

        <?php if($data == 'shoplist' ){ ?>
        <td>
            <a href="<?php echo U('Data/bianji');?>?id=<?php echo $v['id']; ?>">编辑</a>
        </td>
        <?php } ?>

    </tr>
    <?php } ?>
</table>
<div class="result page"><?php echo ($page); ?></div>
</body>
</html>
<script>
    function caochu() {
        var datename = $('#datename').val();
        var datestart = $('#datestart').val();
        var dateend = $('#dateend').val();
        var leykey1 = $('#leykey1').val();
        var leyval1 = $('#leyval1').val();
        var xuanze1 = $('#xuanze1').val();
        var leykey2 = $('#leykey2').val();
        var leyval2 = $('#leyval2').val();
        var xuanze2 = $('#xuanze2').val();
        var leykey3 = $('#leykey3').val();
        var leyval3 = $('#leyval3').val();
        var xuanze3 = $('#xuanze3').val();

        $.ajax({
            type: "post",
            dataType: "text",
            url: "<?php echo U('Data/daochu');?>",
            data: {
                datename: datename,
                datestart: datestart,
                dateend: dateend,
                leykey1: leykey1,
                leyval1: leyval1,
                xuanze1: xuanze1,
                leykey2: leykey2,
                leyval2: leyval2,
                xuanze2: xuanze2,
                leykey3: leykey3,
                leyval3: leyval3,
                xuanze3: xuanze3
            },
            success: function (msg) {
                console.log(msg);
                window.open(msg);
            }
        });
    }
      $(function () {
     $('#add').click(function () {
        window.location.href="<?php echo U('Data/add');?>";
     });
     });
    function del(id) {
        if (confirm("确定要删除吗？")) {
            var url = "<?php echo U('User/deleteuser');?>?uid=" + id;
            window.location.href = url;
        }
    }
</script>
<script type="text/javascript">
    BUI.use('bui/calendar', function (Calendar) {
        var datepicker = new Calendar.DatePicker({
            trigger: '.calendar-time',
            showTime: true,
            autoRender: true
        });
    });
</script>